<?php

namespace App\Services\Api\Other;

use Firebase\JWT\JWT;
use Firebase\JWT\Key;

class OtherService
{
    public static function createToken ($id){
        $key = config('jwt.key');
        $data = [
            'uid' => $id
        ];
        return JWT::encode($data,$key,'HS256');
    }

    public static function parseToken ($token){
        $key = config('jwt.key');
        $data = JWT::decode($token, new Key($key,'HS256'));
        return $data['uid'];
    }

    public static function sendCode ($tel,$code){
        $content="您的验证码为:" . $code . "，验证码5分钟内有效，请您妥善保全并及时使用";//要发送的短信内容
        $sendurl = sprintf(config('smsbao.url'),$tel,$content);
        $result =file_get_contents($sendurl);
        return $result;
    }
}
